<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <title>Components</title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
          name='viewport'/>
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="assets/css/ready.css">
    <link rel="stylesheet" href="assets/css/demo.css">
    <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="assets/layer/layer/theme/default/layer.css"/>
    <script src="../homePage/js/jquery-1.9.1/jquery.js"></script>
    <script src="bootstrap/js/bootstrap.js"></script>
    <script src="angularjs/angular.min.js"></script>
    <script src="assets/layer/layer/layer.js"></script>
    <script src="../homePage/layer/layer.js"></script>

</head>
<style type="text/css">
    .main-panel {
        background-color: #FFFFFF !important;
    }

    .content {
        background-color: #FFFFFF !important;
    }
</style>
<body ng-app="myApp" ng-controller="myCtrl" ng-init="getAllOrderByUserid()">
<div class="wrapper">
    <div class="main-header" style="height: 55px">
        <div class="logo-header">
            <a href="index.html" class="logo">
                <img src="../homePage/img/logo.png" style="height: 40px;width: 100px">个人中心
            </a>
            <button class="navbar-toggler sidenav-toggler ml-auto" type="button" data-toggle="collapse"
                    data-target="collapse"
                    aria-controls="sidebar" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <button class="topbar-toggler more"><i class="la la-ellipsis-v"></i></button>
        </div>
        <a href="../homePage/index.html" style="color: #000000; font-size: 16px;">返回首页</a>
        <nav class="navbar navbar-header navbar-expand-lg float-right">
            <div class="container-fluid">
                <ul class="navbar-nav topbar-nav ml-md-auto align-items-center ">

                    <li class="nav-item dropdown">当前用户:
                        <!--   <a class="dropdown-toggle profile-pic" data-toggle="dropdown" href="#" aria-expanded="false">-->
                        <a class="dropdown-toggle profile-pic" data-toggle="dropdown" href="#" aria-expanded="false">
                            <span>{{username}}</span>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li>
                                <div class="user-box">

                                    <div class="u-text">

                                        <p class="text-muted">hello@themekita.com</p>
                                        <a ng-click="quiet()" class="btn btn-rounded btn-danger btn-sm">退出登录</a>
                                    </div>
                                </div>
                            </li>

                        </ul>
                        <!-- /.dropdown-user -->
                    </li>
                </ul>
            </div>
        </nav>
    </div>
    <div class="sidebar">
        <div class="scrollbar-inner sidebar-wrapper">
            <div class="user">
                <div class="info">
                    <a class="" data-toggle="collapse" href="#collapseExample" aria-expanded="true">

								<span>

									<span class="user-level">修改信息</span>
                                    <!-- <span class="badge badge-count">未实名</span> -->
									<span class="caret"></span>
								</span>
                    </a>
                    <div class="clearfix"></div>

                    <div class="collapse in" id="collapseExample" aria-expanded="true" style="">
                        <ul class="nav">

                            <li>
                                <a href="password.html">
                                    <span class="link-collapse">修改密码</span>
                                </a>
                            </li>
                            <li>
                                <a href="authentication.html">
                                    <span class="link-collapse">实名认证</span>
                                </a>
                            </li>
                            <li>
                                <a href="update.html">
                                    <span class="link-collapse">编辑资料</span>
                                </a>
                            </li>
                            <li>
                                <a href="gobindcar.html">
                                    <span class="link-collapse">绑定车辆</span>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <ul class="nav">
                <li class="nav-item">
                    <a href="home.html">
                        <i class="la la-fonticons"></i>
                        <p>首页管理</p>
                        <!-- <span class="badge badge-count">5</span> -->
                    </a>
                </li>
                <li class="nav-item active">
                    <a href="myOrder.html">
                        <i class="la la-dashboard"></i>
                        <p>我的订单</p>
                        <!-- <span class="badge badge-count">5</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="guarantee.html">
                        <i class="la la-table"></i>
                        <p>我的保单</p>
                        <!-- <span class="badge badge-count">14</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="claim.html">
                        <i class="la la-keyboard-o"></i>
                        <p>我的理赔</p>
                        <!-- <span class="badge badge-count">50</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="notifications.html">
                        <i class="la la-th"></i>
                        <p>我的车辆</p>
                        <!-- <span class="badge badge-count">6</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="applyclaim.html">
                        <i class="la la-th"></i>
                        <p>申请理赔</p>
                        <!-- <span class="badge badge-count">6</span> -->
                    </a>
                </li>
            </ul>
        </div>
    </div>
    <div class="main-panel">
        <div class="content">
            <div class="container-fluid">
                <h4 class="page-title">我的订单</h4>
                <div class="row">
                    <div class="col-md-12">
                        <div class="card" ng-repeat="s in list">
                            <div class="card-header bg-light">
                                <h4 class="card-title"><span style="color: red">{{pmessage}}</span></h4>
                                <!--<h4 class="card-title">车险名:交强险</h4>-->
                                <p class="card-category">
                                    <span style="color: #2b669a">
                                    订单号:&nbsp;{{s.ordernumber}}&nbsp;&nbsp;&nbsp;下单时间:{{s.ordertime | date:"yyyy-MM-dd HH:mm:ss"}}
                                    &nbsp;&nbsp;&nbsp;</span><span style="color: red">审核状态:({{s.checkstate}})</span>
                                    <input type="hidden" id="ordernumber"/>
                                </p>
                            </div>

                            <div class="card-body">
                                <p style="color: blue">
                                    <span class="glyphicon glyphicon-user"></span> 车主:
                                </p>
                                <p>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{s.carmastername}}
                                </p>
                                <p style="color: blue">
                                    <span class="glyphicon glyphicon-bed">车型号:&nbsp;{{s.cartype}}</span>
                                </p>
                                <p>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;车牌号:&nbsp;&nbsp;{{s.carnumber}}
                                </p>
                                <p>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;车架号:&nbsp;&nbsp;{{s.vin}}
                                </p>
                                <p style="color: blue">
                                    <span class=" glyphicon glyphicon-tasks"></span> 保险类型:
                                </p>
                                <p>
                                    &nbsp;&nbsp;&nbsp;&nbsp;{{s.safetype.safename}}
                                </p>
                                <p style="color: blue">
                                    <span class="glyphicon glyphicon-user"> </span>被保人名字:
                                </p>
                                <p>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{s.insuredpersonname}}
                                </p>
                                <p style="color: blue">

                                    <span class="glyphicon glyphicon-credit-card"> </span>被保人身份证号:
                                </p>
                                <p>
                                    &nbsp;&nbsp; &nbsp;&nbsp;{{s.insuredpersonidnumber}}
                                </p>
                                <p style="color: blue">
                                    <span class="glyphicon glyphicon-user">
                                    </span>

                                    审核者:&nbsp;&nbsp;
                                </p>
                                <p>
                                    &nbsp;&nbsp;&nbsp;{{s.auditerid}}号专员
                                </p>
                                <p style="color: blue">
                                    <span class="glyphicon glyphicon-user">
                                    </span>

                                    保险费用:&nbsp;&nbsp;
                                </p>
                                <p>
                                    &nbsp;&nbsp;&nbsp;{{s.price}}
                                </p>
                                <p style="color: blue">
                                    备注:
                                </p>
                                <p style="color: red">
                                    &nbsp;&nbsp;{{s.remark}}
                                </p>

                                <div class="text-left">
                                    <a class="btn btn-success" ng-if="s.checkstate=='审核通过'"
                                       ng-click="payOrder(s.ordernumber)">前往付款</a>
                                    <a class="btn btn-default"
                                       ng-click="cancelOrderByOrdernumber(s.ordernumber)">取消订单</a>
                                    <a class="btn  btn-warning" ng-click="openModal(s.ordernumber)"
                                       ng-if="s.checkstate!='审核通过'">修改订单</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal fade" id="myModal">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-body">
                                    <form class="form-horizontal">
                                        <div class="form-group">
                                            <label for="carmasterName" class="col-sm-3 control-label">车&nbsp;&nbsp;&nbsp;&nbsp;主:</label>
                                            <div class="col-sm-9">
                                                <input type="text" class="form-control" ng-model="carMasterName"
                                                       id="carmasterName" placeholder="请输入修改的车主姓名">
                                            </div>
                                            <label class="col-sm-3 control-label">车&nbsp;&nbsp;架&nbsp;&nbsp;号:</label>
                                            <div class="col-sm-9">
                                                <input type="text" class="form-control" ng-model="vin" id="vin"
                                                       placeholder="请输入修改的车架号">
                                            </div>

                                            <label class="col-sm-3 control-label">车&nbsp;&nbsp;&nbsp;&nbsp;牌：</label>
                                            <div class="col-sm-9">
                                                <input type="text" class="form-control" ng-model="carnumber"
                                                       id="carnumber" placeholder="请输入修改的车牌号">
                                            </div>
                                            <label class="col-sm-3 control-label">被保人姓名：</label>
                                            <div class="col-sm-9">
                                                <input type="text" class="form-control" ng-model="insuName"
                                                       id="insuName" placeholder="请输入修改的被保人姓名">
                                            </div>
                                            <label class="col-sm-3 control-label">被保人身份证:</label>
                                            <div class="col-sm-9">
                                                <input type="text" class="form-control" ng-model="cardId" id="cardId"
                                                       placeholder="请输入修改的被保人身份证">
                                            </div>
                                        </div>
                                    </form>
                                </div>
                                <button type="button" class="btn btn-success" ng-click="updateOrder()">确认修改</button>
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <footer class="footer">
            <div class="container-fluid">
                <nav class="pull-left">
                    <ul class="nav">
                        <li class="nav-item">
                            <a class="nav-link" href="#">
                                ThemeKita
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">
                                Help
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#license/#free-item">
                                Licenses
                            </a>
                        </li>
                    </ul>
                </nav>
                <div class="copyright ml-auto">
                    Copyright &copy; 2020 无忧车险责任有限公司
                </div>
            </div>
        </footer>
    </div>
</div>
</body>


<script>

    //debugger
    var app = angular.module("myApp", []);
    app.controller("myCtrl", function ($scope, $http) {
        var item = sessionStorage.getItem("user");
        $scope.userid = JSON.parse(item).userid;
        $scope.username = JSON.parse(item).username;
        var index = null;
        //查询所有订单
        $scope.getAllOrderByUserid = function () {
            $http.get("http://localhost:8006/order/findAllOrders/" + $scope.userid)
                .success(function (data) {
                    if (data.code == 404) {
                        //   $scope.pmessage="空空如也";
                        index = layer.msg(data.msg, {icon: 6});
                    } else {
                        $scope.list = data.data;
                    }
                });
            $scope.cancelOrderByOrdernumber = function (code) {
                $http.get("http://localhost:8006/order/cancelOrderByOrdernumber/" + code).success(function (data) {
                    index = layer.load(data.msg, {icon: 6});
                    window.location.href = "myOrder.html"
                    //   $scope.getAllOrderByUserid();
                    layer.close(index);
                })
            }
        }

        $scope.quiet = function () {
            sessionStorage.clear();
            window.location.href = "../homePage/index.html";
        }
        $scope.openModal = function (oNo) {
            $http.get("http://localhost:8006/order/findOrderByOrdernumber/" + oNo).success(function (data) {
                $("#carmasterName").val(data.data.carmastername);
                $("#vin").val(data.data.vin);
                $("#carnumber").val(data.data.carnumber);
                $("#insuName").val(data.data.insuredpersonname);
                $("#cardId").val(data.data.insuredpersonidnumber);
            })
            $("#myModal").modal("show");
            $("#ordernumber").val(oNo);
        }
        //订单信息有误则让他再次修改
        $scope.updateOrder = function () {
            var masterName = $("#carmasterName").val();
            var vin = $("#vin").val();
            var carno = $("#carnumber").val();
            var name = $("#insuName").val();
            var id = $("#cardId").val();
            var ono = $("#ordernumber").val();
            //车架号的正则表达式
            var vinexgre = /^[A-HJ-NPR-Z\d]{17}$/;
            //车牌号的正则表达式
            var carnumberexgre = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/;
            //身份证号的正则表达式
            var idreg = /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
            if (masterName == "" || masterName == null || vin == "" || vin == null || carno == "" || carno == null
                || name == "" || name == null || id == "" || id == null) {
                layer.msg("请填写全部信息")
            } else if (vinexgre.test(vin) == false) {
                layer.msg("车架号填写不规范")
            } else if (carnumberexgre.test(carno) == false) {
                layer.msg("车牌号填写不规范")
            } else if (idreg.test(id) == false) {
                layer.msg("身份证号填写不规范")
            } else {
                $http.get("http://localhost:8006/order/updateOrderByOrdernumber?ordernumber" +
                    "=" + ono + "&vin=" + vin + "&carnumber=" + carno + "&insuredpersonname=" + name + "" +
                    "&insuredpersonidnumber=" + id + "&carmastername=" + masterName).success(function (data) {
                    $scope.autoCheckOrder(ono, name, id);
                    $("#myModal").modal("hide");
                    $scope.getAllOrderByUserid();
                })
            }
        }
        $scope.autoCheckOrder = function (No, inname, inid) {
            $http.get("http://localhost:8004/carinfoSource/autoOrderCheck/" + No + "/" + inname + "/" + inid).success(function (data) {
                index = layer.msg(data.msg);
                $scope.getAllOrderByUserid();
               // layer.close(index);

            });

        }
        //支付订单
        $scope.payOrder = function (oNo) {
            $http.get("http://localhost:8006/order/payOrder/" + oNo).success(function (data) {
                window.location.href = "payOrder.html";
            });
        }
    });

</script>
</html>